<?php

namespace App\Http\Controllers;

use App\Att;
use App\Pro;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;

class CheckController extends Controller
{
    public function proList() {
        $pro = Pro::get();

        return view('prolist',['pro'=>$pro]);
    }

    public function checkFrom($id){
        $pro = Pro::find($id);
        return view('shenhe',['pro'=>$pro]);
    }

    //审核入库
    public function checkStore(Request $req) {
        $pro = Pro::find($req->pid);
        $pro->title = $req->input('title');
        $pro->money = ($req->input('money'))*100;
        $pro->hrange = $req->hrange;
        $pro->rate = $req->rate;
        $pro->status = $req->status;

        //附表
        $att = Att::find($req->pid);
        $att->marry = $req->input('marry');
        $att->title = $req->input('title');

        $att->salary = ($req->salary)*1000;
        $att->jobcity = $req->input('jobcity');
        $att->gender = $req->input('gender');
        $att->udesc = $req->input('udesc');
        $att->realname = $req->input('realname');

        if ($pro->save() && $att->save()) {
            return redirect(url('check'));
        } else {
            return '审核失败';
        }

    }
}
